import 'package:flutter/material.dart';

class TimelineViewModel with ChangeNotifier {
  final List<TimelineItem> timelineData = [
    TimelineItem(
      time: 'January 2025',
      title: 'RMB 8934.54',
      subtitle: '5',
      confirmed: true,
      events: [
        const TimelineEvent('January 7th', 'Received a transfer of 200 RMB'),
        const TimelineEvent('January 12th', 'Received a transfer of 500 RMB'),
        const TimelineEvent('January 18th', 'Received a red packet of 100 RMB'),
        const TimelineEvent('January 21th', 'Received interest of 34.54 RMB'),
        const TimelineEvent('January 25th', 'Recorded salary of 8000 RMB'),
      ],
    ),
    TimelineItem(
      time: 'December 2024',
      title: 'RMB 9105.88',
      subtitle: '5',
      confirmed: true,
      events: [
        const TimelineEvent('December 6th', 'Received a transfer of 250 RMB'),
        const TimelineEvent('December 11th', 'Received a transfer of 600 RMB'),
        const TimelineEvent(
            'December 17th', 'Received a red packet of 150 RMB'),
        const TimelineEvent('December 20th', 'Received interest of 55.88 RMB'),
        const TimelineEvent('December 26th', 'Recorded salary of 8050 RMB'),
      ],
    ),
    TimelineItem(
      time: 'November 2024',
      title: 'RMB 8643.20',
      subtitle: '4',
      confirmed: true,
      events: [
        const TimelineEvent('November 4th', 'Received a transfer of 300 RMB'),
        const TimelineEvent(
            'November 12th', 'Received a red packet of 120 RMB'),
        const TimelineEvent('November 18th', 'Received interest of 43.20 RMB'),
        const TimelineEvent('November 24th', 'Recorded salary of 8180 RMB'),
      ],
    ),
    TimelineItem(
      time: 'October 2024',
      title: 'RMB 8230.50',
      subtitle: '5',
      confirmed: true,
      events: [
        const TimelineEvent('October 3rd', 'Received a transfer of 200 RMB'),
        const TimelineEvent('October 9th', 'Received a transfer of 500 RMB'),
        const TimelineEvent('October 15th', 'Received a red packet of 100 RMB'),
        const TimelineEvent('October 21st', 'Received interest of 30.50 RMB'),
        const TimelineEvent('October 27th', 'Recorded salary of 7400 RMB'),
      ],
    ),
    TimelineItem(
      time: 'September 2024',
      title: 'RMB 7780.40',
      subtitle: '4',
      confirmed: true,
      events: [
        const TimelineEvent('September 5th', 'Received a transfer of 400 RMB'),
        const TimelineEvent(
            'September 13th', 'Received a red packet of 80 RMB'),
        const TimelineEvent('September 19th', 'Received interest of 30.40 RMB'),
        const TimelineEvent('September 25th', 'Recorded salary of 7270 RMB'),
      ],
    ),
    TimelineItem(
      time: 'August 2024',
      title: 'RMB 8015.65',
      subtitle: '5',
      confirmed: true,
      events: [
        const TimelineEvent('August 2nd', 'Received a transfer of 300 RMB'),
        const TimelineEvent('August 8th', 'Received a transfer of 450 RMB'),
        const TimelineEvent('August 14th', 'Received a red packet of 120 RMB'),
        const TimelineEvent('August 17th', 'Received interest of 45.65 RMB'),
        const TimelineEvent('August 23rd', 'Recorded salary of 7100 RMB'),
      ],
    ),
    TimelineItem(
      time: 'July 2024',
      title: 'RMB 7540.30',
      subtitle: '4',
      confirmed: true,
      events: [
        const TimelineEvent('July 6th', 'Received a transfer of 200 RMB'),
        const TimelineEvent('July 12th', 'Received a red packet of 150 RMB'),
        const TimelineEvent('July 18th', 'Received interest of 40.30 RMB'),
        const TimelineEvent('July 24th', 'Recorded salary of 7150 RMB'),
      ],
    ),
    TimelineItem(
      time: 'June 2024',
      title: 'RMB 7220.70',
      subtitle: '5',
      confirmed: true,
      events: [
        const TimelineEvent('June 3rd', 'Received a transfer of 150 RMB'),
        const TimelineEvent('June 9th', 'Received a transfer of 300 RMB'),
        const TimelineEvent('June 15th', 'Received a red packet of 100 RMB'),
        const TimelineEvent('June 20th', 'Received interest of 20.70 RMB'),
        const TimelineEvent('June 26th', 'Recorded salary of 6650 RMB'),
      ],
    ),
    TimelineItem(
      time: 'May 2024',
      title: 'RMB 8340.25',
      subtitle: '5',
      confirmed: true,
      events: [
        const TimelineEvent('May 4th', 'Received a transfer of 350 RMB'),
        const TimelineEvent('May 9th', 'Received a transfer of 400 RMB'),
        const TimelineEvent('May 14th', 'Received a red packet of 90 RMB'),
        const TimelineEvent('May 19th', 'Received interest of 40.25 RMB'),
        const TimelineEvent('May 28th', 'Recorded salary of 7460 RMB'),
      ],
    ),
    TimelineItem(
      time: 'April 2024',
      title: 'RMB 7035.60',
      subtitle: '4',
      confirmed: true,
      events: [
        const TimelineEvent('April 6th', 'Received a transfer of 250 RMB'),
        const TimelineEvent('April 12th', 'Received a red packet of 100 RMB'),
        const TimelineEvent('April 17th', 'Received interest of 35.60 RMB'),
        const TimelineEvent('April 25th', 'Recorded salary of 6650 RMB'),
      ],
    ),
    TimelineItem(
      time: 'March 2024',
      title: 'RMB 8120.40',
      subtitle: '5',
      confirmed: true,
      events: [
        const TimelineEvent('March 3rd', 'Received a transfer of 300 RMB'),
        const TimelineEvent('March 8th', 'Received a transfer of 200 RMB'),
        const TimelineEvent('March 15th', 'Received a red packet of 150 RMB'),
        const TimelineEvent('March 18th', 'Received interest of 20.40 RMB'),
        const TimelineEvent('March 26th', 'Recorded salary of 7450 RMB'),
      ],
    ),
    TimelineItem(
      time: 'February 2024',
      title: 'RMB 6852.15',
      subtitle: '4',
      confirmed: true,
      events: [
        const TimelineEvent('February 2nd', 'Received a transfer of 200 RMB'),
        const TimelineEvent('February 9th', 'Received a red packet of 120 RMB'),
        const TimelineEvent('February 14th', 'Received interest of 32.15 RMB'),
        const TimelineEvent('February 22nd', 'Recorded salary of 6500 RMB'),
      ],
    ),
    TimelineItem(
      time: 'January 2024',
      title: 'RMB 7426.30',
      subtitle: '5',
      confirmed: true,
      events: [
        const TimelineEvent('January 5th', 'Received a transfer of 150 RMB'),
        const TimelineEvent('January 10th', 'Received a transfer of 400 RMB'),
        const TimelineEvent('January 16th', 'Received a red packet of 80 RMB'),
        const TimelineEvent('January 19th', 'Received interest of 26.30 RMB'),
        const TimelineEvent('January 24th', 'Recorded salary of 6770 RMB'),
      ],
    ),
    TimelineItem.complete()
  ];
}

class TimelineItem {
  final String time;
  final String title;
  final String subtitle;
  final bool confirmed;
  final List<TimelineEvent> events;

  TimelineItem({
    required this.time,
    required this.title,
    required this.subtitle,
    required this.confirmed,
    required this.events,
  });

  bool get isCompleted => title == "Done";

  const TimelineItem.complete()
      : title = 'Done',
        time = '',
        subtitle = '',
        confirmed = false,
        events = const [];
}

class TimelineEvent {
  const TimelineEvent(this.createdAt, this.message);

  final String createdAt;
  final String message;

  @override
  String toString() {
    return '$createdAt $message';
  }
}
